package priorityqueue;

import java.util.Comparator;
import java.util.PriorityQueue;

class IntComparator implements Comparator<Integer> {

    @Override
    public int compare(Integer o1, Integer o2) {
        return o2.compareTo(o1);
    }
}

public class Test {
    public static void main(String[] args) {
        IntComparator intComparator = new IntComparator();
        PriorityQueue<Integer> p = new PriorityQueue<>(intComparator);
        p.offer(4);
        p.offer(3);
        p.offer(2);
        p.offer(1);
        p.offer(5);
        System.out.println(p.peek());
    }
}
